package com.example.springbatchsample.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.JobParameter;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 启动监听器
 *
 * @author Yunkai Luo
 * @since 2022/1/28
 **/
@Slf4j
@Component
public class LauncherListener extends StepExecutionListenerSupport {

    @Override public void beforeStep(StepExecution stepExecution) {
        Map<String, JobParameter> parameters = stepExecution.getJobParameters().getParameters();
        JobParameter msg = parameters.get("msg");
        log.error(String.valueOf(msg.getValue()));
    }

}
